package com.mantbox.channelcall.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mantbox.channelcall.dao.UrlLinkMapper;
import com.mantbox.channelcall.entity.UrlLink;
import com.mantbox.channelcall.service.UrlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UrlServiceImpl implements UrlService {


    @Autowired
    UrlLinkMapper urlLinkMapper;

    @Override
    public PageInfo<UrlLink> pageList(Integer page, Integer pageSize, Integer groupId, Integer usePageMode) {
        if (usePageMode != null && usePageMode == 1) {
            PageHelper.startPage(page,pageSize);
        }
        List<UrlLink> urlLinks = urlLinkMapper.pageList(null,groupId,null);
        return new PageInfo<>(urlLinks);
    }

    @Override
    public Integer batchUpdateUrlStatus(List<UrlLink> list) {
        return urlLinkMapper.batchUpdateUrlStatus(list);
    }

    @Override
    public UrlLink selectById(Integer id) {
        return urlLinkMapper.selectByPrimaryKey(id);
    }

    @Override
    public void resetClick() {
        urlLinkMapper.resetClick();
    }
}
